package com.xyz.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class JpaTestController {

    @Autowired
    private UserRepostory userRepostory;

    @GetMapping("/insert")
    public String insert(Model model){
        User user = userRepostory.save(new User(1,"小白","1@1.com"));
        userRepostory.flush();
        model.addAttribute("result","插入数据成功 - "+user.toString());
        return "insert";
    }
}
